package com.ycz;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author ycz
 * @date 2021/6/18
 * @description TODO
 * @Company © 版权所有 深圳市天行云供应链有限公司
 */
@Component
public class UserFactoryBean implements FactoryBean {

    public Object getObject() throws Exception {
//        return new User();
        Object o = Proxy.newProxyInstance(UserFactoryBean.class.getClassLoader(), new Class[]{UserMapper.class}, new InvocationHandler() {
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                System.out.println("UserFactoryBean=="+method.getName());
                return null;
            }
        });
        return o;
    }

    public Class<?> getObjectType() {
        return UserFactoryBean.class;
    }
}
